package main

import (
	"fmt"
	"os"
	"bufio"
)

func main() {
	const fname string="test.txt"
	f,ferr:=os.OpenFile(fname, os.O_WRONLY|os.O_CREATE, 0666)
	if ferr != nil {
		fmt.Fprintln(os.Stderr, "error opening")
		os.Exit(1)
		return
	}
	defer f.Close()
	fmt.Fprintln(f, "hello from Fprintln to f")

	writer:=bufio.NewWriter(f)
	writer.WriteString("hello from writer\n")
	fmt.Fprintln(writer, "hello from Fprintln to writer")
	writer.Flush()

	f.WriteString("f.WriteString()\n")
}
